const msg = require('fs')
    .readFileSync('.git/COMMIT_EDITMSG', 'utf-8')
    .trim()

const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/;
const mergeRE = /^(Merge pull request|Merge branch)/;
if (!commitRE.test(msg)) {
    if (!mergeRE.test(msg)) {
        console.log('git commit is not valid!');
        console.error(`git commit's info is wrong, need title(scope): desc format
            e.g. fix: xxbug
            feat(test): add new
            see scripts/verifyCommit.js
            `);
        process.exit(1);
    }
} else {
    console.log('git commit passed');
}
